/**
 * @file audio_player.h
 *
 */
#ifndef AUDIO_PLAYER_H
#define AUDIO_PLAYER_H

#ifdef __cplusplus
extern "C" {
#endif

/*********************
*      INCLUDES
*********************/

#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lvgl.h"
#include "lv_watch_conf.h"
#else
#include "../../../lvgl/lvgl.h"
#include "../../../lv_watch_conf.h"
#endif

#if USE_LV_WATCH_AUDIO_PLAYER != 0

/*********************
*      DEFINES
*********************/
/* File attribute bits for directory entry (for ui used)*/
#define AUDIO_FILE_DIR    0x10    /* Directory */
#define AUDIO_FILE_ARC    0x20    /* Archive, normal file */
#define AUDIO_FILE_HID    0x40    /* Hidden, hide(or system) dir(or file) */
#define AUDIO_PATH_MAX    260
#define AUDIO_EXT_NAME    "mp3"
#define AUDIO_EXT_NAME_SUB    "MP3"
#define AUDIO_SD_FS_LETTER 'D'
#ifndef BUILD_IN_PC_SIMULATOR
#define AUDIO_ROOT_PATH   "D:\\*"
#else
#define AUDIO_ROOT_PATH   "C:/*"
#endif
#ifndef BUILD_IN_PC_SIMULATOR
#define ADUIO_FILE_SYSTEM_PATH  "D:\\audio_list.nv"
#else
#define ADUIO_FILE_SYSTEM_PATH  "C:/audio_list.nv"
#endif
#define AUDIO_CURRENT_INDEX_INVALID 0XFFFFFFFF
#define AUDIO_SD_MOUNTED_AS_U_STORAGE -1
#define AUDIO_PAGE_MAX_NUM 5
#define AUDIO_LESS_SPACE_NUM 1024
/**********************
*      TYPEDEFS
**********************/
typedef struct {
    char path[AUDIO_PATH_MAX];
    char filename[AUDIO_PATH_MAX];
} audio_info_t;

typedef struct
{
    lv_cont_ext_t oldext;
    lv_obj_t     *label_title;
    lv_obj_t     *label_time_s;   /*hour:min:sec*/
    lv_obj_t     *img_btn_start_pause;
    lv_obj_t     *img_btn_prev;
    lv_obj_t     *img_btn_next;
    lv_obj_t     *img_btn_plus;
    lv_obj_t     *img_btn_minus;
    uint32_t     count;
    lv_obj_t     *btn_sub[AUDIO_PAGE_MAX_NUM];
    lv_obj_t     *img_order;
    lv_obj_t     *img_shuffle;
    lv_obj_t     *img_all_repeat;
    lv_obj_t     *img_repeat_once;
    lv_obj_t     *slider;
} lv_audio_player_ext_t;

/**********************
* GLOBAL PROTOTYPES
**********************/

/**
 * Create a audio_player application
 */
lv_obj_t *audio_player_create(lv_obj_t *par);
void audio_player_create_event_cb(lv_obj_t * btn, lv_event_t e);

extern uint8_t setting_get_ring_volume(void);
extern void audio_player_handle_bt_handset_connect_cnf(uint8_t connect);
#if USE_LV_WATCH_SD_AUTO_MOUNT != 0
void audio_player_for_mount_destory(void);
#endif
#if USE_LV_SD_FS
void audio_player_for_sd_mount(void);
void audio_player_for_sd_unmount(void);
#endif
void audio_player_create_tab(lv_obj_t * par);
void audio_player_destroy_tab(lv_obj_t * tab);
void audio_player_lowbattery_process(void);

/**********************
*      MACROS
**********************/

#endif /*USE_LV_WATCH_AUDIO_PLAYER*/

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /*AUDIO_PLAYER_H*/
